<?php

    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'category-form',
        'enableAjaxValidation' => false,
        'enableClientValidation' => true,
        'htmlOptions' => array(
            'class' => 'form-horizontal',
             'enctype' => 'multipart/form-data'
        ),
    ));
?>
<div class="row-fluid">
    <div class='add'>
    <div class="span12">
<!--        <div class="control-group" style="margin-top: 25px; color: red; font-weight: bold">
            <label for="Ticket_ticket_code" class="control-label"  >TYPE NORMAL</label>    
        </div>-->
        <!--PAGE CONTENT BEGINS-->
        
        <div class="control-group" style="margin-top: 40px;">
            <?php echo $form->labelex($model, 'ranking', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->textField($model, 'type_of_ticket', array('size' => 60, 'maxlength' => 255, 'value'=>$model->ranking,  'class' => 'span5 quantity', 'placeholder' => '0->xx')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'type_of_ticket'); ?></span>
            </div>
        </div>
        
        <div class="control-group">
            <?php echo $form->labelex($model, 'description_of_ticket', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->textField($model, 'description_of_ticket', array('size' => 60, 'maxlength' => 255, 'class' => 'span5', 'placeholder' => 'VIP Seat, Luxury Seat, Normal Seat. ')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'description_of_ticket'); ?></span>
            </div>
        </div>
        
        <div class="control-group">
            <?php echo $form->labelex($model, 'price', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->textField($model, 'price', array('size' => 60, 'maxlength' => 255, 'class' => 'price', 'placeholder' => 'Price','readonly' => true)); ?> / VNĐ
                <span class="help-inline"><?php echo $form->error($model, 'price'); ?></span>
            </div>
        </div>

        <div class="control-group">
            <?php echo $form->labelex($model, 'quantity', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->textField($model, 'quantity', array('size' => 60, 'maxlength' => 255, 'class' => 'span5 quantity', 'placeholder' => 'Total','readonly' => true)); ?>
                <span class="help-inline"><?php echo $form->error($model, 'quantity'); ?></span>
            </div>
        </div>
        <div class="control-group">
            <?php echo $form->labelex($model, 'temp_quantity', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->textField($model, 'temp_quantity', array('value' => $model->tempQuantityText,'size' => 60, 'maxlength' => 255, 'class' => 'span5', 'placeholder' => 'Ex: Decrease: -50, Increase: 50')); ?>
                <br />
                <span class="help-inline" style="color:red;">Every input, please seperate it with comma (,)</span>
                <br />
                <span class="help-inline" style="color:red;">Add more ticket, and if you want to return ticket to your organizer(subtraction quantity)</span>
                <span class="help-inline"><?php echo $form->error($model, 'quantity'); ?></span>
            </div>
        </div>
        <div class="control-group">
            <?php echo $form->labelex($model, 'ticket_code_org', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->textField($model, 'ticket_code_org', array('size' => 60, 'maxlength' => 255, 'class' => 'span5', 'placeholder' => 'X143234#1232')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'ticket_code_org'); ?></span>
            </div>
        </div>
       
        <div class="control-group">
            <?php echo $form->labelex($model, 'seat_map', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->dropDownlist($model, 'seat_map', array(0=>'No', 1=>'Yes'),array('class' => 'span5','id'=>'seat1', 'placeholder' => 'Seat Map')); ?>
                <span class="help-inline"><?php echo $form->error($model, 'seat_map'); ?></span>
            </div>
        </div>    

        <div class="control-group file1 hide1">
            <?php echo $form->labelex($model, 'fileImage', array('class' => 'control-label')); ?>
            <div class="controls">
                <?php echo $form->fileField($model, 'fileImage', array('class' => 'id-input-file-1 span5')); ?>
                <span class="help-inline" style="float:left;margin-left:390px;"><?php echo $form->error($model, 'fileImage'); ?></span>
            </div>
            <?php if($model->pic_seat_map != NULL && $model->seat_map == 1): ?>
                <div class="column" style="width: 98%; padding:15px 0 15px 0;">
                    <img src="<?php echo Yii::app()->createAbsoluteUrl('/data/pic/'.$model->pic_seat_map);?>"  style="width:200px;margin-left: 118px;" height="100";/>
                </div>            
            <?php endif; ?>
        </div>
    <!--</div>-->
    
    
</div>
</div>
    <div class="form-actions">
        <button class="btn btn-info" type="submit">
            <i class="icon-ok bigger-110"></i>
            Submit
        </button>
        &nbsp; &nbsp; &nbsp;
        <button class="btn" type="reset">
            <i class="icon-undo bigger-110"></i>
            Reset
        </button>
    </div>    
<?php $this->endWidget(); ?>

<script>
    $(document).ready(function(){
        var a = $('#seat1').val();
        if (a === '1') {
            $('.file1').removeClass('hide1');
        } 
        else{
            $('.file1').addClass('hide1');
        }
    });
    
    $('#seat1').on('change', function(){
        var a = $(this).val();
        if (a === '1') {
            $('.file1').removeClass('hide1');
        }
        else{
            $('.file1').addClass('hide1');
        }
    });
//    $('#seat2').on('change', function(){
//        var a = $(this).val();
//        if (a === '1') {
//            $('.file2').removeClass('hide2');
//        }
//    });
//    $('#seat3').on('change', function(){
//        var a = $(this).val();
//        if (a === '1') {
//            $('.file3').removeClass('hide3');
//        }
//    });
    
    
    
//    function validateNumber(){
            $(".price").on('click', function(){
                    $(this).unbind("keydown");
                    $(this).bind("keydown",function(event){
                        if( !(event.keyCode == 8                                // backspace
                            || event.keyCode == 46                              // delete
                            || event.keyCode == null                      // delete
                            || event.keyCode == 9							// tab
                            || (event.keyCode == 190 || event.keyCode == 110 )							// dấu chấm (point) 
                            || (event.keyCode >= 35 && event.keyCode <= 40)     // arrow keys/home/end
                            || (event.keyCode >= 48 && event.keyCode <= 57)     // numbers on keyboard
                            || (event.keyCode >= 96 && event.keyCode <= 105))   // number on keypad
                            ) {
                                event.preventDefault();     // Prevent character input
                            }
                    });
            });
            
            $(".quantity").on('click', function(){
                    $(this).unbind("keydown");
                    $(this).bind("keydown",function(event){
                        if( !(event.keyCode == 8                                // backspace
                            || event.keyCode == 46                              // delete
                            || event.keyCode == null                      // delete
                            || event.keyCode == 9							// tab
//                            || (event.keyCode == 190 || event.keyCode == 110 )							// dấu chấm (point) 
                            || (event.keyCode >= 35 && event.keyCode <= 40)     // arrow keys/home/end
                            || (event.keyCode >= 48 && event.keyCode <= 57)     // numbers on keyboard
                            || (event.keyCode >= 96 && event.keyCode <= 105))   // number on keypad
                            ) {
                                event.preventDefault();     // Prevent character input
                            }
                    });
            });
//    }
</script>

<style>
    .price{
        width: 363px;
    }
    
    .ace-file-input {
        width: 378px;
    } 
    
    .hide1, .hide2, .hide3{
        display: none;
    }
</style>